using UnityEngine;
using UnityEngine.UI;

public class UIRateAppPanel : MonoBehaviour, IBackAction
{
	public Text topText;

	private string templateTopString = "<color=#f8df0dff>{0}</color> {1}<size=55>\n{2}</size>";

	private bool visible;

	private void Awake()
	{
		Globals.instance.backManager.RegisterObject(this);
	}

	private void Start()
	{
		string stringWithNewLines = LanguageController.instance.GetStringWithNewLines("RateApp_DiscYellow");
		string stringWithNewLines2 = LanguageController.instance.GetStringWithNewLines("RateApp_DiscWhite52");
		string stringWithNewLines3 = LanguageController.instance.GetStringWithNewLines("RateApp_DiscWhite55");
		topText.text = string.Format(templateTopString, stringWithNewLines, stringWithNewLines2, stringWithNewLines3);
	}

	public void OnCloseButtonPressed()
	{
		OnBackAction();
	}

	public void OnRateAppButtonPressed()
	{
		if (visible)
		{
			UserPreferences.instance.playerData.gameRated = true;
			UserPreferences.instance.Save();
		//	Application.OpenURL(Globals.instance.rateAppLink);
			OnBackAction();
		}
	}

	public void OnApear()
	{
		visible = true;
	}

	public void OnHide()
	{
		UnityEngine.Object.Destroy(base.gameObject);
	}

	public void OnBackAction()
	{
		if (visible)
		{
			GetComponent<Animator>().SetTrigger("Hide");
			visible = false;
		}
	}
}
